Total Complexity | 2 |
Total Lines | 25 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import { |
||
19 | |||
20 | @Controller('quotes') |
||
21 | @ApiUseTags('Billing') |
||
22 | @ApiBearerAuth() |
||
23 | @UseGuards(AuthGuard('bearer')) |
||
24 | export class CreateQuoteAction { |
||
25 | constructor( |
||
26 | @Inject('ICommandBus') |
||
27 | private readonly commandBus: ICommandBus, |
||
28 | @Inject('IQueryBus') |
||
29 | private readonly queryBus: IQueryBus |
||
30 | ) {} |
||
31 | |||
32 | @Post() |
||
33 | @ApiOperation({title: 'Create new quote'}) |
||
34 | public async index(@Body() quoteDto: QuoteDTO, @LoggedUser() user: User) { |
||
35 | try { |
||
36 | const {projectId, customerId} = quoteDto; |
||
37 | const id = await this.commandBus.execute( |
||
38 | new CreateQuoteCommand(user, customerId, projectId) |
||
39 | ); |
||
40 | |||
41 | return id; |
||
42 | } catch (e) { |
||
43 | throw new BadRequestException(e.message); |
||
44 | } |
||
47 |